home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VCLEARA.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  16KB  |  545 lines

  1. ;«RM83»«TS8,16,24,32,40,48»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .MODEL MEDIUM, BASIC
  15.  
  16. .data
  17.     ;external data so all video routines can access
  18.     EVEN
  19.     EXTRN  B$DVIDEOSEG:WORD
  20.     EXTRN  B$DVIDEOPORT:WORD
  21.     EXTRN  B$DVIDEOINSTL:BYTE
  22. .code
  23.  
  24. INCLUDE  NOWAIT.INC
  25. EXTRN    Get_Adapter:FAR
  26.  
  27. comment         |
  28. Calc_DI_Offset_Addr  macro
  29.     ;; standard routine
  30.     ;; Note destroys AX, BX, CL
  31.     ;;               ;8086  ;80286
  32.     Mov   AX,CurrRow   ;14     ;5
  33.     Dec   AX           ;3      ;2   ;;change from 1-25 to 0-24
  34.     Mov   cl,160       ;4      ;2
  35.     Mul   cl           ;77     ;13  ;;multiply CurrRow by 160
  36.     Mov   BX,BegCol    ;14     ;5   ;;get starting column
  37.     Dec   BX           ;3      ;2   ;;change from 1-80 to 0-79
  38.     Shl   BX,1         ;2      ;2   ;;multiply (CurrRow-1) by 2
  39.     Add   AX,BX        ;3      ;2   ;;get offset
  40.     Mov   DI,AX        ;3      ;2   ;;move to source index
  41.     endm               ;---------
  42.                ;123    ;35  ;;clocks
  43.         |
  44.  
  45. Calc_DI_Offset_Addr    macro
  46.     ;; This is slightly slower in the abstract
  47.     ;; sense on a 80286.  Cannot observe the difference
  48.     ;; on a 8088 with a CGA because of delay waiting for retrace.
  49.     ;; Though if have an 8088 with MONO or VGA/EGA it is faster
  50.     ;;
  51.     ;; Input:     Nothing
  52.     ;; Output:    DI = Memory Offset
  53.     ;; Destroys:  CX,AX
  54.     ;; Macro is used because inline code speeds routine
  55.     ;;               ;8088 ;80286
  56.     Xor     CL, CL     ;3    ;2   ;; Clear CL
  57.     Mov     AX,CurrRow ;14   ;5   ;; get starting Row
  58.     Dec     AX         ;3    ;2   ;; change from 1-25 to 0-24
  59.     Mov     CH, AL     ;2    ;2   ;; CX = Row * 256
  60.     Shr     CX, 1      ;2    ;2   ;; CX = Row * 128
  61.     Mov     DI, CX     ;2    ;2   ;; Store in DI
  62.     Shr     DI, 1      ;2    ;2   ;; DI = Row * 64
  63.     Shr     DI, 1      ;2    ;2   ;; DI = Row * 32
  64.     Add     DI, CX     ;3    ;2   ;; DI = (Row * 128)+(Row * 32)={Row*160}
  65.     Xor     CH, CH     ;3    ;2   ;; Clear CH register
  66.     Mov     AX,BegCol  ;14   ;5   ;; get starting Column
  67.     Dec     AX         ;3    ;2   ;; change from 1-80 to 0-79
  68.     Mov     CL, AL     ;2    ;2   ;; CX = Columns
  69.     Shl     CX, 1      ;2    ;2   ;; Account for attribute
  70.     Add     DI, CX     ;3    ;2   ;; DI = (Row * 160) + (Col * 2)
  71.               ;--------
  72.       endm                ;60    ;36  ;; clocks
  73.  
  74. .code
  75. ;=====================Some data variables==================================
  76. ;         Stored in Code segment to save space in DGROUP
  77.  
  78. EVEN
  79. CurrRow        DW    0           ;current CurrRow
  80. BegCol         DW    0           ;Starting Column
  81. Num_Cols       DW    0           ;words to copy per line
  82. EndingRow      DW    0           ;Ending Row
  83. BACKCOLOR      DW    0           ;store shadow color for MAKEBOXES
  84. Color          DB    0           ;Store color attribute
  85.  
  86.  
  87. ;===========================================================================
  88. ; DECLARE SUB
  89. ; CLEARAREA (BYVAL ULR%, BYVAL ULC%, BYVAL LRR%, BYVAL LRC%, BYVAL ATTRIB%)
  90. ; CALL CLEARAREA (ULR%, ULC%, LRR%, LRC%, ATTRIB%)
  91. ; Changes the attribute of an area on the screen in text mode
  92. ;===========================================================================
  93.  
  94. EVEN
  95. CLEARAREA Proc FAR BASIC USES SI DI, \
  96. ULR:Word, ULC:Word, LRR:Word, LRC:Word, ATTRIB:Word
  97.  
  98. comment |
  99.     Register usage when all done:
  100.     AH = Color attribute to change line to
  101.     AL = loading point for STOB, scratch.
  102.     CX = Number of characters to change on a line.
  103.     DX = Port for CGA video retrace check, if necessary.
  104.         0 means display is not a not a CGA display
  105.     DI = Offset of Screen for current character
  106.     ES = Segment of Video display, 0xB000 or 0xB800
  107.     BX = is used as a scratch variable register
  108.     DS & SI are not changed
  109.      |
  110.  
  111.     Cmp   B$DVIDEOINSTL,1
  112.     JE    Didit
  113.     Call  Get_Adapter       ;determine the display type routine
  114. Didit:
  115.     Mov   ES,B$DVIDEOSEG    ;store Video Segment in ES
  116.     Mov   DX,B$DVIDEOPORT   ;Get B$VDIDEOPORT
  117.  
  118.     Mov   BX,ULC           ;get first column
  119.     Mov   BegCol,BX
  120.  
  121.     Mov   BX,LRC           ;get last column
  122.     Cmp   BX,80
  123.     JBE   @f
  124.     Mov   BX,80            ; make sure right margin not > 80
  125.                    ; so no wrap around on left margin
  126. @@:
  127.     Sub   BX,BegCol        ;subtract last column from first column
  128.     Inc   BX               ;add 1 to get number of columns to print
  129.     Mov   Num_Cols,BX      ;BX equals number of words to copy per line
  130.  
  131.     Mov   BX,LRR           ;get last line
  132.     Mov   EndingRow,BX
  133.  
  134.     Mov   BX,ULR           ;get first line
  135.     Mov   CurrRow,BX       ;set current row to first line
  136.  
  137.     Calc_DI_Offset_Addr    ;calculate offset for line MACRO
  138.     Mov   CX,Num_Cols      ;load counter with words to copy
  139.     JCXZ  Exit2            ;if CX is zero it's a zero length line
  140.                    ;so exit now
  141.  
  142.     Mov   BX,ATTRIB        ;get the color ATTRIBUTE% that was passed
  143.     Mov   AX,BX            ;put it into AH for screen writing below
  144.     Mov   Color,AL
  145.     Cld                    ;clear the direction flag to move data forward
  146. EVEN
  147. Main2:
  148.     Mov   AH,Color         ;get attribute & put it in AH
  149.     Mov   AL,AH            ;get attribute & put it in AL
  150.     Or    DL,DL            ;are we on a mono or EGA system?
  151.     JZ    Mono2            ;yes, skip over the retrace stuff
  152. EVEN
  153. CGA2:
  154.     CLI                    ;prevent hardware interrupts
  155.     Wait_CGA_Retrace       ;wait for retrace on CGA MACRO
  156.     Mov   AL,AH            ;get attribute & put it in AL
  157.     Inc   DI
  158.     Stosb                  ;store the attribute
  159.     STI                    ;allow interrupts again
  160.     Loop  CGA2             ;loop until CX is zero
  161.     Jmp  Short Next_Line2
  162. EVEN
  163. Mono2:
  164.     Inc   DI               ;the increment before store allows one
  165.                    ;to change just the color attribute
  166.     Stosb                  ;store the attribute
  167.     Loop  Mono2            ;loop until CX is zero
  168. Next_Line2:
  169.     Mov   AX,EndingRow
  170.     Cmp   AX,CurrRow       ;Are we done restoring window?
  171.     Je    Exit2            ;exit if complete
  172.     INC   CurrRow          ;next line
  173.     Calc_DI_Offset_Addr    ;compute new offset address MACRO
  174.     Mov   CX,Num_Cols      ;set counter to # of words to copy
  175.     JMP Short Main2        ;jump to print next line
  176. Exit2:
  177.     Ret                    ;return skipping the passed parameters
  178. CLEARAREA   Endp
  179.  
  180. ;===========================================================================
  181. ; DECLARE SUB BACKFILL
  182. ;(BYVAL ULR%, BYVAL ULC%, BYVAL LRR%, BYVAL LRC%, BYVAL ATTRIB%, BYVAL TEXTCHAR%)
  183. ; CALL BACKFILL(ULR%, ULC%, LRR%, LRC%, ATTRIB%, TEXT$)
  184. ; Fills the display area with a character and a fixed text attribute
  185. ;===========================================================================
  186.  
  187. EVEN
  188. BACKFILL Proc FAR BASIC USES DI SI, \
  189. ULR:Word, ULC:Word, LRR:Word, LRC:Word, ATTRIB:Word, TEXTS:Word
  190.  
  191. comment |
  192.     Register usage when all done:
  193.     AH = Color attribute to change line to
  194.     AL = loading point for text character.
  195.     CX = Number of characters to change on a line.
  196.     DX = Port for CGA video retrace check, if necessary.
  197.          0 means display is not a not a CGA display
  198.     DI = Offset of Screen for current character
  199.     ES = Segment of Video display, 0xB000 or 0xB800
  200.     BX = is used as a scratch variable register
  201.     SI = holds the text & character attribute
  202.     DS  is not changed
  203.      |
  204.  
  205.     Cmp   B$DVIDEOINSTL,1
  206.     JE    Didit1
  207.     Call Get_Adapter        ;determine the display type routine
  208.  
  209. Didit1:
  210.     Mov   ES,B$DVIDEOSEG    ;store Video Segment in ES
  211.     Mov   DX,B$DVIDEOPORT   ;Get B$VDIDEOPORT
  212.  
  213.     Mov   BX,ULC           ;get first column
  214.     Mov   BegCol,BX
  215.  
  216.     Mov   BX,LRC           ;get last column
  217.     Cmp   BX,80
  218.     JBE   @f
  219.     Mov   BX,80            ; make sure right margin not > 80
  220.                    ; so no wrap around on left margin
  221. @@:
  222.     Sub   BX,BegCol        ;subtract first column from last column
  223.     Inc   BX               ;add 1 to get number of columns to print
  224.     Mov   Num_Cols,BX      ;BX equals number of words to copy per line
  225.